package lab02.test03;

/**
 * Created by 婷婷 on 2017/10/15.
 */
public class Student {
    //属性:学生的姓名，性别，年龄，学号，计算机网络的成绩，数学成绩，英语成绩
    public String name;
    public String sex;
    public int age;
    public int num;
    public int computerNetworkScore;
    public int mathScore;
    public int englishScore;


    //构造函数


    public Student(String name, String sex, int age, int num,
                   int computerNetworkScore, int mathScore, int englishScore) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.num = num;
        this.computerNetworkScore = computerNetworkScore;
        this.mathScore = mathScore;
        this.englishScore = englishScore;
    }

    /**
     * 返回学生的详细信息
     *
     * @return
     */
    @Override
    public String toString() {
        //将要输出的信息复制给字符串变量studentInfo
        String studentInfo = "学生的基本信息有：姓名："+name+"\n性别："+sex+"\n年龄："+age+"\n学号"+num+
                "\n计算机网络成绩"+computerNetworkScore+"\n数学成绩"+mathScore+"\n英语成绩"+englishScore+
                "\n------------------------------------\n学生总成绩："+scoreSum()+"\n学生的平均成绩："+scoreAve()
                +"\n学生的最高成绩"+scoreMax()+"\n学生的最低成绩"+scoreMin();
        //返回学生信息
        return studentInfo;
    }

    public float scoreSum() {
        return computerNetworkScore + mathScore + englishScore;
    }

    public float scoreAve(){
        return (computerNetworkScore + mathScore + englishScore)/3;
    }

    public float scoreMax(){
        float scoreMax=(computerNetworkScore > mathScore)?computerNetworkScore : mathScore;
        scoreMax = scoreMax > englishScore ? scoreMax:englishScore;
        return  scoreMax;
    }

    public float scoreMin(){
        float scoreMin=(computerNetworkScore < mathScore)?computerNetworkScore : mathScore;
        scoreMin = scoreMin < englishScore ? scoreMin:englishScore;
        return  scoreMin;
    }


}
